<%@ page language="java" contentType="text/html; charset=utf-8"%>
<%@ include file="/WEB-INF/layouts/base.jsp"%>
<!DOCTYPE HTML>
<html>
  <head>
    <title>
    	<c:if test="${empty user}">创建用户</c:if>
    	<c:if test="${!empty user }">修改用户</c:if>
    </title>
    <link rel="stylesheet" href="${basePath}/static/common/select2/select2.css" />
    <script src="${basePath}/static/admin/main/js/add-user.js" type="text/javascript"></script>
    
    <script src="${basePath}/static/common/select2/select2.min.js"></script>
    <script type="text/javascript">
    	$(function(){
    		$('#roleId').select2({
    			allowClear: true
    		});
    	})
    </script>
  </head>
  
  <body class="gray-bg">
    <div class="wrapper add-member-content animated fadeInRight">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5><c:if test="${empty user}">创建用户<small>  用户个人信息时应当遵循合法、正当、必要的原则，明示目的、方式和范围，并经用户同意。</small></c:if><c:if test="${!empty user}">修改用户信息</c:if> </h5>
                        <div class="ibox-tools">
                            <a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
                            <a class="close-link"><i class="fa fa-times"></i></a>
                        </div>
                    </div>
                    <div class="ibox-content">
                        <form id="userform" class="form-horizontal">
                            <div class="form-group m-t">
                            	<label class="col-sm-2 control-label">登录名:</label>
								<div class="col-sm-4">
									<div class="input-icon right">
										<i class="fa"></i>
	                                	<input type="text" class="form-control" required name="loginName" value="${user.loginName}"/>
	                                	<!-- 为了防止修改用户时也发送ajax请求检查用户是否存在 -->
	                                	<input type="hidden" id="_loginName" value="${user.loginName }"/>
                                	</div>
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                            <div class="form-group m-t">
                            	<label class="col-sm-2 control-label">昵称:</label>
								<div class="col-sm-4">
									<div class="input-icon right">
										<i class="fa"></i>
	                                	<input type="text" class="form-control" required name="name" value="${user.name}"/>
                                	</div>
                                </div>
                            </div>
                            
                            <div class="hr-line-dashed"></div>
                            <c:if test="${empty user}">
                            	<div class="form-group">
								<label class="col-sm-2 control-label">密码:</label>
								<div class="col-sm-4">
									<div class="input-icon right">
										<i class="fa"></i>
	                                	<input type="password" class="form-control" required name="plainPassword"/>
                                	</div>
                                </div> 
                                </div>
                                <div class="hr-line-dashed"></div> 
							</c:if>
                            <div class="form-group">
                            	<label class="col-sm-2 control-label">角色:</label>
                            	<div class="col-sm-4">
									<div class="input-icon right">
										<i class="fa"></i>
	                                	<select class="form-control select2" style="padding: 0;" id="roleId" multiple>
							        		<c:forEach items="${roleList}" var="role">
							        			<option value="${role.id}" <c:if test="${role.userHas}">selected</c:if>>${role.roleName}</option>
							        		</c:forEach>
							        	</select>
	        							<input type="hidden" id="roleIds" name="roleIds"/>
                                	</div>
                                </div> 
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">状态:</label>
                                <div class="col-sm-4">
                                <c:if test="${empty user}">
                                   <!-- <label class="radio-inline add-radio"> -->
                                        <input type="radio" name="lock" value="0" checked="checked">  开启</label>
                                </c:if>
                                <c:if test="${!empty user}">
                                   <label class="radio-inline add-radio">
                                        <input type="radio" name="lock" value="0" <c:if test="${!user.lock }">checked="checked"</c:if> >  开启</label>
                                </c:if>
                                    <!-- <label class="radio-inline add-radio"> -->
                                        <input type="radio" name="lock" value="1" <c:if test="${user.lock }">checked="checked"</c:if> >  关闭</label>
                                </div>
                            </div>
                            
                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <div class="col-sm-4 col-sm-offset-2 add-submit">
                                <input type="hidden" class="form-control" name="id" value="${user.id}" id="userId">
                                <input class="btn btn-primary" type="button" id="userSubmit" value="提交"/>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>
</html>
